#include "GHashGenerator.h"

namespace GUtil
{

	GSize GHashGenerator::GenerateHash(const char* String)
	{
		GSize HashOutput = 0;
		while(*String != '\0')
		{
			HashOutput = (GSize)((GUInt8)*String) + (HashOutput << 6) + (HashOutput << 16) - HashOutput;
			String++;
		}
		return HashOutput;
	}

	GSize GHashGenerator::GenerateHash(const void* Value, GSize Size)
	{
		GSize HashOutput = 0;
		for (GSize I = 0; I < Size; I++)
			HashOutput = (GSize)((GUInt8*)Value)[I] + (HashOutput << 6) + (HashOutput << 16) - HashOutput;

		return HashOutput;
	}

	void GHashGenerator::GenerateHash(GSize& HashOutput, const char* String)
	{
		while(*String != '\0')
		{
			HashOutput = (GSize)((GUInt8)*String) + (HashOutput << 6) + (HashOutput << 16) - HashOutput;
			String++;
		}
	}

	void GHashGenerator::GenerateHash(GSize& HashOutput, const void* Value, GSize Size)
	{
		for (GSize I = 0; I < Size; I++)
			HashOutput = (GSize)((GUInt8*)Value)[I] + (HashOutput << 6) + (HashOutput << 16) - HashOutput;
	}

}; // namespace GUtil